define(function(require, exports){
    //var pubjs = require('pubjs');
    //var view = require('@base/view');
    var util  = require('util');
    var $ = require('jquery');
    //var d3Chart = require('modules/d3Chart');

    var highGrid = require('@base/highGrid');

    var grid = highGrid.base.extend({

        //重新对表格渲染
        renderAllCols:function(cols,metrics,amount){

            var data = this.$data && this.$data.items || null;
            var amountData = this.$data && this.$data.amount || [];
            var cfg = this.getConfig();

            if(amountData && amountData.length > 0){
                this.reRender(amountData,amount.trs, cfg.metrics);
            }
            this.reRender(data,cols.trs, cfg.col);
            this.reRender(data,metrics.trs, cfg.metrics);
            this.calculate();
        },

        //重新渲染单元格
        reRender:function(data,elems,elemsConfig){
            var self = this;
            var row,dataTds,tdAttr,tdConfig;

            for(var i = 0;data && i< data.length ; i++){
                row = elems[i];
                dataTds = $(row).find('td');
                for(var j= 0; j< dataTds.length; j++){
                    tdAttr = $(dataTds[j]).data('name');
                    tdConfig = util.find(elemsConfig,tdAttr,"name");
                    if(tdConfig && tdConfig.renderChart && util.isFunc(self[tdConfig.renderChart])){
                        if(data[i][tdAttr]){
                            var guid = util.guid();
                            $(dataTds[j]).attr('id',tdAttr + '_'+ guid);
                            self[tdConfig.renderChart](data[i][tdAttr],'#'+ tdAttr + "_" + guid);
                        }
                    }
                }

            }

        }

    });

    exports.base = grid;



});